regex_replace
Returns the text obtained by replacing all subsequences in this text which match the given regular expression regex, with the text replacement.
Supports named and numbered group references in the replacement text.
Examples:
'aaaaacaaaaabaaaaacaaaaa'.regex_replace('(b|c)', 'd')returns'aaaaadaaaaadaaaaadaaaaa'.'aaaaacaaaaabaaaaacaaaaa'.regex_replace('a+', '')returns'cbc'.'johnsmith@chromaway.com'.regex_replace('[a-z]+', '0')returns'0@0.0'.'John Doe'.regex_replace('(\\w+) (\\w+)', '$2, $1')returns'Doe, John'.'2025-10-27'.regex_replace('(?<y>\\d{4})-(?<m>\\d{2})-(?<d>\\d{2})', '${d}/${m}/${y}')returns'27/10/2025'.
Return
text equal to this, but with regions that match regex replaced with replacement
Since
0.14.16
Parameters
the regular expression to search with
the replacement text
Throws
if regex is not a valid regular expression